import 'package:audioplayers/audioplayers.dart';

///
/// 音频工具
///
class AsrAudioPlayer {
  static final AudioPlayer _player = AudioPlayer();

  ///
  /// 播放语音识别开启提示音
  ///
  static Future<void> playStartSound() async {
    return await _player.play(
      AssetSource('sounds/record_start.mp3'),
      volume: 1,
      mode: PlayerMode.lowLatency,
    );
  }

  ///
  /// 播放语音识别成功提示音
  ///
  static Future<void> playSuccessSound() async {
    return await _player.play(
      AssetSource('sounds/record_success.caf'),
      volume: 1,
      mode: PlayerMode.lowLatency,
    );
  }

  ///
  /// 播放网络音频
  ///
  static Future<void> playNetworkSound(String url) async {
    return await _player.play(
      UrlSource(url),
      volume: 1,
      mode: PlayerMode.lowLatency,
    );
  }
}
